<template>
  <div class="waterUsageStatistics">
    <TitleColumn name="用水统计" />
    <div class="content">
      <div class="statistics">
        <div class="overview">
          <h3><CountTo :startVal="1" :endVal="167832" :duration="3000" /></h3>
          <p>总用水量(m³)</p>
        </div>
        <ul class="street">
          <li>
            <div class="waveChart">
              <WaveSVG />
              <strong>54%</strong>
              <div class="circle"></div>
            </div>
            <section>
              <h3><CountTo :startVal="1" :endVal="176384" :duration="3000" /></h3>
              <p>雄州街道(m³)</p>
            </section>
          </li>
          <li>
            <div class="waveChart">
              <WaveSVG />
              <strong>60%</strong>
              <div class="circle"></div>
            </div>
            <section>
              <h3><CountTo :startVal="1" :endVal="176384" :duration="3000" /></h3>
              <p>横梁街道(m³)</p>
            </section>
          </li>
          <li>
            <div class="waveChart">
              <WaveSVG />
              <strong>32%</strong>
              <div class="circle"></div>
            </div>
            <section>
              <h3><CountTo :startVal="1" :endVal="176384" :duration="3000" /></h3>
              <p>龙袍街道(m³)</p>
            </section>
          </li>
        </ul>
        <div class="quota">
          <h3><CountTo :startVal="1" :endVal="176384" :duration="3000" /></h3>
          <p>用水控制指标(m³)</p>
        </div>
      </div>
      <!-- 图表主体 -->
      <div class="chartContent" ref="chartRef"></div>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref, reactive, onMounted } from 'vue';
  import { CountTo } from '@gui-pkg/components';
  import { useECharts } from '@gui-pkg/hooks';
  import setChartOption from './chartOption';
  import TitleColumn from '@/components/TitleColumn';
  import WaveSVG from './WaveSVG.vue';

  defineOptions({ name: 'WaterUsageStatistics' });

  const chartRef = ref<HTMLDivElement | null>(null);
  const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
  const state = reactive({
    name: 'vue3',
  });

  onMounted(() => {
    const chartOption = setChartOption();
    setOptions(chartOption);
  });
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .waterUsageStatistics {
    width: 100%;
    .content {
      width: 100%;
      height: calc(100% - 30px);
      background: #02123433;
      backdrop-filter: blur(10px);
      padding: 10px 10px 10px 10px;
      .statistics {
        width: 650px;
        height: 80px;
        border: 1px solid;
        border-image: linear-gradient(90deg, rgba(2, 110, 194, 0.16) 0%, rgba(2, 110, 194, 0.8) 49%, rgba(2, 110, 194, 0.16) 100%);
        border-image-slice: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .overview {
          width: 98px;
          height: 84px;
          background: url(./images/bg.png) no-repeat;
          background-size: contain;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
        }
        ul.street {
          height: 100%;
          display: flex;
          align-items: center;
          li {
            width: 150px;
            height: 50px;
            display: flex;
            justify-content: center;
            .waveChart {
              width: 88px;
              height: 88px;
              position: relative;
              margin-right: 8px;
              transform: scale(0.6);
              margin-top: -20px;
              margin-left: -20px;
              &:after {
                content: '';
                display: inline-block;
                width: 100%;
                height: 100%;
                background: url(./images/decorate.png) no-repeat;
                background-size: 100% 100%;
                position: absolute;
                top: 0px;
              }
              strong {
                font-size: 20px;
                color: #fff;
                box-shadow: 0px 2px 4px 0px #002851A8;
                position: absolute;
                top: 30%;
                left: 50%;
                transform: translateX(-50%);
                z-index: 100;
              }
              .circle {
                width: 92px;
                height: 92px;
                background: url(./images/circle.png) no-repeat;
                background-size: contain;
                animation: spin 3s linear infinite;
                position: absolute;
                top: 0;
                z-index: 100;
                &:before {
                  content: '';
                  display: inline-block;
                  width: 8px;
                  height: 8px;
                  background: #fff;
                  border-radius: 50%;
                  position: absolute;
                  right: 3px;
                  bottom: 24px;
                  z-index: 1000;
                }
                &:after {
                  content: '';
                  display: inline-block;
                  width: 18px;
                  height: 18px;
                  background: url(./images/shadow.png) no-repeat;
                  background-size: contain;
                  position: absolute;
                  right: -2px;
                  bottom: 20px;
                }
              }
            }
            section {
              margin-left: -20px;
            }
          }
        }
        .quota {
          width: 100px;
          height: 100%;
          background: linear-gradient(270deg, rgba(2, 110, 194, 0.7) 0%, rgba(2, 110, 194, 0) 100%);
          border-left: 1px solid #026EC28F;
          display: flex;
          align-items: center;
          flex-direction: column;
          justify-content: center;
        }
        h3 {
          color: #fff;
          font-size: 18px;
          transform: scaleY(1.1);
        }
        p {
          color: #fff;
          font-size: 11px;
        }
      }
      .chartContent {
        width: 100%;
        height: calc(100% - 80px);
      }
    }
    @keyframes spin {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }
  }
</style>
